package cn.yeziji.forum.controller;

import cn.yeziji.forum.common.ForumResult;
import cn.yeziji.forum.common.Paging;
import cn.yeziji.forum.dao.intf.ForumShareLinkDao;
import cn.yeziji.forum.dto.shareLink.ShareLinkDTO;
import cn.yeziji.forum.utils.ForumResultUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 分享链接控制器
 *
 * @author gzkemays
 * @since 2022/11/11 4:00 PM
 */
@RestController
@RequestMapping("/share")
public class ForumShareLinkController {
  @Resource ForumShareLinkDao shareLinkDao;

  @PostMapping("/submit")
  public ForumResult submit(@RequestBody ShareLinkDTO dto) {
    shareLinkDao.submit(dto);
    return ForumResultUtils.ok();
  }

  @GetMapping("/audit")
  public ForumResult audit(@RequestParam("id") String id) {
    shareLinkDao.audit(id);
    return ForumResultUtils.ok();
  }

  @GetMapping("/list")
  public ForumResult list(Paging paging) {
    return ForumResultUtils.ok(shareLinkDao.list(paging));
  }
}
